﻿<Window 
    x:Class="FB2er.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="{Binding Title}" 
    AllowDrop="True" 
    Background="WhiteSmoke"
    Closing="Window_Closing"
    >
    <Window.Resources>
        <RoutedCommand x:Key="cmdRecentBook"/>
        <RoutedCommand x:Key="cmdAbout"/>
        <RoutedCommand x:Key="cmdFullScreen"/>
        <Style x:Key="recentBookMenuItemStyle" TargetType="MenuItem">
            <Setter Property="Command" Value="{StaticResource cmdRecentBook}"/>
        </Style>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Key="F11" Command="{StaticResource cmdFullScreen}" />
    </Window.InputBindings>
    <Window.CommandBindings>
        <CommandBinding Command="Open" Executed="ExecuteOpen"/>
        <CommandBinding Command="{StaticResource cmdRecentBook}" Executed="ExecuteOpenRecent"/>
        <CommandBinding Command="{StaticResource cmdAbout}" Executed="ExecuteAbout"/>
        <CommandBinding Command="{StaticResource cmdFullScreen}" Executed="ExecuteFullScreen"/>        
    </Window.CommandBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Menu>
            <MenuItem Header="_File">
                <MenuItem Command="Open"/>
                <MenuItem 
                    Header="Recent Books" 
                    ItemsSource="{Binding RecentBooks}"
                    ItemContainerStyle="{StaticResource recentBookMenuItemStyle}"
                    />
                <MenuItem Header="About..." Command="{StaticResource cmdAbout}"/>
                <MenuItem Header="Exit" InputGestureText="Alt+F4"/>
            </MenuItem>
            <MenuItem Header="_View">
                <MenuItem Header="Full Screen" Command="{StaticResource cmdFullScreen}" InputGestureText="F11"/>
            </MenuItem>
        </Menu>
        <FlowDocumentReader x:Name="fdr" Grid.Row="1" Background="White">
            <FlowDocument x:Name="doc" Background="White" DragOver="DocDragOver" Drop="DocDrop"/>
        </FlowDocumentReader>
    </Grid>
</Window>
